package ma.jee.portailReservation.persistence.person;

import ma.jee.portailReservation.persistence.reservation.Reglement;

import javax.persistence.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by IntelliJ IDEA.
 * User: soufiane
 * Date: 22/12/11
 * Time: 00:56
 * To change this template use File | Settings | File Templates.
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "Client",
        uniqueConstraints =
                {@UniqueConstraint(columnNames = {
                        "idClient", "userName"})})
public class Client implements Serializable{
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name ="idClient")
    private long idClient;
    @Column(name ="lastName", nullable = false)
    private String lastName;
    @Column(name ="firstName", nullable = false)
    private String firstName;
    @Column(name ="passportNumber")
    private String passportNumber;
    @Column(name ="address", nullable = false)
    private String address;
    @Column(name ="telephone", nullable = false)
    private String telephone;
    @Column(name ="email", nullable = false)
    private String email;
    @Column(name ="cardNumber")
    private String cardNumber;
     @Column(name ="userName", nullable = false)
    private String userName;
    @Column(name ="password", nullable = false)
    private String password;

   /*  @ManyToMany( cascade = CascadeType.ALL , fetch = FetchType.EAGER
		      )
    @JoinTable(
		      name = "ReglementsClients",
		      joinColumns = { @JoinColumn(name = "idClient") },
		      inverseJoinColumns = { @JoinColumn(name = "idReglement") }
		      )
    */
    @OneToMany(mappedBy = "client", fetch = FetchType.LAZY, cascade =  CascadeType.ALL)
    private Set<Reglement> reglements = new HashSet<Reglement>();



    public long getIdClient() {
        return idClient;
    }

     public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getPasswportNumber() {
        return passportNumber;
    }

    public void setPassportNumber(String passwportNumber) {
        this.passportNumber = passwportNumber;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

     public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getCardNumber() {
        return cardNumber;
    }

    public String getTelephone() {
        return telephone;
    }

    public String getUserName() {
        return userName;
    }

    public String getPassword() {
        return password;
    }

    public Set<Reglement> getReglements() {
        return reglements;
    }

    public void setIdClient(long id) {
        this.idClient = id;
    }

    public void setCardNumber(String cardNumber) {
        this.cardNumber = cardNumber;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public void setUserName(String username) {
        this.userName = username;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setReglements(Set<Reglement> reglements) {
        this.reglements = reglements;
    }
}
